{extend name="public/common"}

{block name="style"}
<title>资源中心</title>
<link rel="stylesheet" href="/home/css/resource/index.css?v={$Think.config.version}">
<style>
    .list {
         margin: 0;
    }
</style>
{/block}

{block name="body"}
<div id="app" v-cloak>
    <div class="list">
        <ul>
            <li v-for="item in list.folder" @click="toDetail(item.id,item.name)" v-if="user.permission == 1 || (user.permission > 1 && item.id == user.departmentid)">
                <div>
                    <i class="fa fa-folder-open"></i><p>{{item.name}}资料库</p><i class="fa fa-angle-right"></i>
                </div>

            </li>
        </ul>
        <div class="empty" v-if="list.folder.length == 0">
            <img class="empty-img" src="/home/images/common/empty.png" alt="">
            <p class="empty-title">暂无内容，敬请期待</p>
            <p class="empty-text">to be continued...</p>
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script>
    console.log({$list})
    console.log({$user})
    var vw = new Vue({
        el: "#app",
        data: {
            list: {$list},
            search: '',
            searchList: [],
            showSearch: false,
            user:{$user}
        },
        methods: {
            getSearch() {
                console.log(this.search)
                var _this = this;
                _this.$indicator.open({
                    text: '正在搜索中',
                    spinnerType: 'triple-bounce'
                });
                _this.$http.post('{:Url("Resource/search")}',{name:this.search},{emulateJSON:true}).then(function (res) {
                    var data = res.body;
                    console.log(data)
                    _this.$indicator.close();
                    if(data.code == 1){
                        _this.searchList = data.data;
                        _this.showSearch = true
                    }else{
                        _this.$toast({
                            message: "未搜索到相应内容",
                            duration: 1500
                        });
                    }
                }, function (res) {
                    _this.$indicator.close();
                    _this.$toast({
                        message: "搜索失败，请重试！",
                        duration: 1500
                    });
                });
            },
            delSearch() {
                this.searchList = [];
                this.search = '';
            },
            toUpload() {
                window.location.href = '/home/resource/fileupload.html'
            },
            toDetail(id,name) {
                window.location.href = '/home/resource/index2/top_id/'+id+'.html';

                window.sessionStorage.setItem('folder',name);
            },
            getFile(path) {
                window.location.href = path;
            }
        }
    })
</script>
{/block}
